<?include_once('common/autoload.php');
if(!$_SESSION['memberID']){exit("<script>window.location='dlogin.html'</script>");}
$tpl=Tpl::getLink();
$id = $_REQUEST["id"] + 0;// 模板 ID
$pri = $_REQUEST["pri"];// 配置结算价
$pid = $_REQUEST["pid"];// 产品 pid
$title=$_REQUEST["title"];// 模板名称
exit;
$_pri=array();
print_r($_REQUEST);
exit;
foreach($pid as $v){
	$_pri[$v]=$pri[$v];
}
if($id){
	if(($res=$tpl->upd($id,$_pri))===true){
		echo "<script>alert('修改成功');parent.window.location='addtpl.html?id=".$id."';</script>";
	}
	else{
		echo "<script>alert('".$res."');</script>";
	}
}
else{
	if(filter_var(($res=$tpl->add($_SESSION['memberID'],$title,$_pri)), FILTER_VALIDATE_INT)===false){
		echo "<script>alert('".$res."')</script>";
	}
	else{
		echo "<script>alert('添加成功。');parent.window.history.go(-2);</script>";//parent.window.opener=null;parent.window.close();
	}
}
?>